package com.bw.services.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.bw.services.R
import com.google.vr.sdk.widgets.pano.VrPanoramaView
import com.therouter.router.Route

@Route(path = "app/VrActivity")
class VrActivity : AppCompatActivity() {
    private lateinit var vrPanoramaView: VrPanoramaView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_vr)

        vrPanoramaView = findViewById(R.id.vr_panorama_view)

        // 加载全景图片
        val options = VrPanoramaView.Options()
        options.inputType = VrPanoramaView.Options.TYPE_MONO
        val inputStream = resources.openRawResource(R.drawable.qqqq)
        vrPanoramaView.loadImageFromBitmap(
            android.graphics.BitmapFactory.decodeStream(inputStream),
            options
        )
    }

    override fun onPause() {
        super.onPause()
        vrPanoramaView.pauseRendering()
    }

    override fun onResume() {
        super.onResume()
        vrPanoramaView.resumeRendering()
    }

    override fun onDestroy() {
        vrPanoramaView.shutdown()
        super.onDestroy()
    }
}